(*第一步：转移文件夹
注意：这一部分没有经过测试

*)
CopyDirectory[
 FileNameJoin[{oriPath, #}] & /@ dir,
 FileNameJoin[{newPath, #}] & /@ dir
 ]



DeleteDirectory[
 FileNameJoin[{oriPath, #}] & /@ (StringSplit[#, "\\"][[-1]] & /@ 
    FileNames[All, newPath]),
 DeleteContents -> True
 ]





(*第二步：生成bat命令*)
oriPath = "C:\\Users\\Administrator\\AppData\\Roaming";
(*newPath=InputString["请输入新的AppData路径"];*)
newPath = "E:\\CDataTransfer\\AppData\\Roaming";


(*获取已经转移到新目录下的所有文件夹，并排除掉Mathematica等几个已经事先创建好的文件夹*)
list = FileNames[All, oriPath]~Select~((FileType@# == Directory) &);
dirlist = StringSplit[#, "\\"][[-1]] & /@ list;
exceptlist = {"Mathematica", "Notepad++", "Microsoft", 
   "InsLogicCfg"};
dir = If[SubsetQ[exceptlist, {#}], # /. # -> Nothing, #] & /@ dirlist


(*创建命令合集*)
batdata = ("mklink " <> "\"" <> oriPath <> "\\" <> # <> "\" /d " <> 
      "\"" <> newPath <> "\\" <> # <> "\"") & /@ dir;
Export[newPath <> "\\创建硬链接.txt", batdata];
RenameFile[newPath <> "\\创建硬链接.txt", newPath <> "\\创建硬链接.bat"]




